<?php
namespace common\action;

use herosphp\http\HttpRequest;
use herosphp\utils\AjaxResult;
use herosphp\bean\Beans;
/**
 * demo action
 * @package commom\action
 * @author yangjian<yangjian102621@gmail.com>
 */
 class LoginAction extends CommonAction {

	public function login(HttpRequest $request)
	{

		$url = urldecode($request->getParameter('url'));
		$this->assign('url',$url);
		$this->setView('login');
	}

	public function loginHandle(HttpRequest $request)
	{
		$account = $request->getParameter('account');
		$password = $request->getParameter('password');
		$loginService = Beans::get('login');
		$admin = $loginService->login($account,$password);
		if($admin && is_array($admin))
		{
			AjaxResult::ajaxResult(AjaxResult::OP_SUCCESS,$company);
		}
		AjaxResult::ajaxResult(AjaxResult::OP_FAILURE,$admin);

	}

	public function logout(HttpRequest $request){


		session_destroy();	
		header("location:/");
	}

	public function nopriv(HttpRequest $request)
	{
		$this->setView('deny');
	}

}
